package com.mmy.controller.restaurant;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mmy.domain.restaurant.VRestaurantBase;
import com.mmy.domain.restaurant.VRestaurantPlan;
import com.mmy.service.impl.restaurant.TRestaurantBaseServiceImpl;
import com.mmy.service.impl.restaurant.VRestaurantBaseServiceImpl;
import com.mmy.service.impl.restaurant.VRestaurantPlanServiceImpl;

/**
 * 类的介绍：餐馆计划信息
 *
 * @author shangzl
 * @date 创建日期：2020-08-11
 * @version 1.0
 */
@Controller
public class VRestaurantPlanController {

	@Autowired
	VRestaurantPlanServiceImpl vRestaurantPlanServiceImpl;
	@Autowired
	TRestaurantBaseServiceImpl tRestaurantBaseServiceImpl;
	@Autowired
	VRestaurantBaseServiceImpl vRestaurantBaseServiceImpl;

	/**
	 * 函数功能说明： 跳转
	 *
	 * @param 参数说明
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人 shangzl
	 * @date 创建日期2020-08-11
	 */
	@RequestMapping(value = "/restaurantplan")
	public String ToRestaurantPlan(Model model) {
		try {

			List<VRestaurantPlan> lstRestaurantPlan = vRestaurantPlanServiceImpl.findAll();
			model.addAttribute("newRestaurantPlanList", lstRestaurantPlan);
			List<VRestaurantBase> lstRestaurantBase = vRestaurantBaseServiceImpl.findAll();
			model.addAttribute("newLstRestaurantBase", lstRestaurantBase);

			return "webbackground/restaurantmanagement/restaurantplan";
		} catch (Exception e) {

		}
		return null;

	}

	/**
	 * 函数功能说明： 修改餐馆计划
	 *
	 * @param 参数说明
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人 shangzl
	 * @date 创建日期
	 */

	@RequestMapping(value = "/toupdaterestaurantplan")
	public String toUpdateRestaurantPlan(HttpServletRequest request, Model model) {

		int iPlanID = Integer.parseInt(request.getParameter("iPlanID"));

		VRestaurantPlan vRestaurantPlan = vRestaurantPlanServiceImpl.findByPlanID(iPlanID);
		model.addAttribute("newVRestaurantPlan", vRestaurantPlan);
		List<VRestaurantBase> lstRestaurantBase = vRestaurantBaseServiceImpl.findAll();
		model.addAttribute("newLstRestaurantBase", lstRestaurantBase);

		return "webbackground/restaurantmanagement/updaterestaurantplan";

	}

	/* 跳转查看计划详情 */
	@RequestMapping(value = "/restaurantplaninfo")
	public String ToRestaurantPlanInfo(HttpServletRequest request, Model model) {

		int iPlanID = Integer.parseInt(request.getParameter("iPlanID"));

		VRestaurantPlan vRestaurantPlan = vRestaurantPlanServiceImpl.findByPlanID(iPlanID);
		model.addAttribute("newVRestaurantPlan", vRestaurantPlan);

		return "webbackground/restaurantmanagement/restaurantplaninfo";
	}

	/* 搜索 */
	/**
	 * 函数功能说明： 查询餐馆计划信息
	 *
	 * @param 参数说明
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人 shangzl
	 * @date 创建日期 2020-08-06
	 */
	@RequestMapping(value = "/searchrestaurantplan")
	public String FindRestaurantPlan(HttpServletRequest request, Model model) {

		String strRestaurantID = request.getParameter("RestaurantID");
		List<VRestaurantPlan> lstRestaurantPlan = new ArrayList<VRestaurantPlan>();
		if (strRestaurantID == "") {
			lstRestaurantPlan = vRestaurantPlanServiceImpl.findAll();

		} else {
			lstRestaurantPlan = vRestaurantPlanServiceImpl.findByRestaurantID(Integer.parseInt(strRestaurantID));

		}
		model.addAttribute("newRestaurantPlanList", lstRestaurantPlan);
		List<VRestaurantBase> lstRestaurantBase = vRestaurantBaseServiceImpl.findAll();
		model.addAttribute("newLstRestaurantBase", lstRestaurantBase);
		return "webbackground/restaurantmanagement/restaurantplan";

	}
}
